using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Adge.BLL;
using FAQComponents.API;

namespace Adge.Web.UI
{
    public partial class SignIn : AdgePageBase
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void lgnSignin_LoggingIn(object sender, LoginCancelEventArgs e)
        {
            string userId = lgnSignin.UserName;
            string pwd = lgnSignin.Password;
            if (UserAPI.IsValidCredentials(userId, pwd))
            {
                FormsAuthentication.SetAuthCookie(userId, lgnSignin.RememberMeSet);
                HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(userId, lgnSignin.RememberMeSet), true);
                //FormsAuthentication.RedirectFromLoginPage(username.Text, rememberMe.Checked);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(typeof(Login), "invalidLogin", "<script language=\"JavaScript\">alert('Your username and/or password are invalid.  Please try again.');</script>");
            }
            //string userId = lgnSignin.UserName;
            //string password = lgnSignin.Password;
            //Account acc = new Account();
            //if (acc.ValidateUser(userId, password))
            //{
            //    FormsAuthentication.SetAuthCookie(userId, false);
            //    HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(userId, false), true);
            //}
            //else
            //{
            //    //FormsAuthentication.RedirectToLoginPage();
            //}
        }

        
    }
}
